home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu659.dms / pu659.adf / Scion / ARexx / PrintDescendant.rexx < prev    next >
OS/2 REXX Batch file  |  1994-05-21  |  18KB  |  656 lines

  1. /****************************************************************************
  2.  *                                                                          *
  3.  * $VER: PrintDescendant 1.12 (1 Mar 1994)
  4.  *                                                                          *
  5.  *                      Written by Freddy Ariës                             *
  6.  *                                                                          *
  7.  * Output options:                                                          *
  8.  *  1. Descendant Chart - all descendants [Dutch: parenteel]                *
  9.  *  2. Descendant Chart - male descendants (mention daughters, no children) *
  10.  *     [Dutch: genealogie - nageslacht van zonen, maar vermelding dochters] *
  11.  *  3. Descendant Chart - male descendants (leave out daughters)            *
  12.  *     [Dutch: stamboom - nageslacht van zonen, geen vermelding dochters]   *
  13.  *                                                                          *
  14.  * This version uses (by default) the rexxreqtools.library (which requires  *
  15.  * a version of reqtools larger than 2.0 and rexxsyslib.library)            *
  16.  * If you do not have any of these, you need to supply the NOREQ argument,  *
  17.  * except when you supply the QUIET argument.                               *
  18.  *                                                                          *
  19.  * TO DO:                                                                   *
  20.  *  - count the number of lines output and give a linefeed after a certain  *
  21.  *    number (ie. skip page breaks)                                         *
  22.  *  - add a menu option for the maximum number of generations to print      *
  23.  *  - allow user to specify if he wants burial data printed, occupation,    *
  24.  *    comments, references fields, ....                                     *
  25.  *  - If the person has multiple marriages, output a list to the            *
  26.  *    screen and let the user select one (1..x), or all (0).                *
  27.  *  - If a way is implemented to ask the current IRN from the program,      *
  28.  *    allow the usage of that value instead of asking for an IRN.           *
  29.  *                                                                          *
  30.  ****************************************************************************/
  31.  
  32. options results
  33. arg prtin prsirn outname noirn mgen outval
  34.  
  35. versionstr = "1.12"
  36. usereq = 1; /* change this to 0 if you don't want to use reqtools */
  37. outp = 1; useirn = 1; prtdev = stdout; prtopt = 0
  38. NL = '0A'x
  39.  
  40. signal on IOERR
  41.  
  42. do while prtin = '?'
  43.   Tell("NUMOPT/A/N,PERSONIRN/A/N,OUTFILE/A,NOIRN/S,MAXGEN/N,NOREQ/S,QUIET/S: ")
  44.   pull prtin prsirn outname noirn mgen outval
  45. end
  46.  
  47. ParseArguments()
  48.  
  49. if usereq & ~show('l','rexxreqtools.library') then do
  50.   if exists('libs:rexxreqtools.library') then
  51.     call addlib('rexxreqtools.library',0,-30,0)
  52.   else do
  53.     usereq = 0; outp = 1
  54.     Tell("Unable to open rexxreqtools.library - using text output")
  55.   end
  56. end
  57.  
  58. /* These few lines were stolen from Peter Billings - thanks Peter ;-) */
  59. if ~show('P','SCIONGEN') then do
  60.   TermError('I am sorry to say that the SCION Genealogist' || NL ||,
  61.     'database is not available. Please start the' || NL ||,
  62.     'SCION program BEFORE using this script!')
  63. end
  64.  
  65. myport = "SCIONGEN"
  66. address value myport
  67. GETDBNAME
  68. dbname = upper(RESULT)
  69. plwidth = 78;  /* linewidth of the printer */
  70. fill = 7;      /* number of spaces at the beginning of lines */
  71. malesex = 'M'; /* there are no locale functions in Scion yet... */
  72.  
  73. if outp & ~usereq then do
  74.   Tell("*** PrintDescendant version "||versionstr||" ***")
  75.   Tell("***        by Freddy Ariës       ***")
  76.   Tell("Current database: "||dbname||NL)
  77. end
  78. if prtopt = 0 then do
  79.   if usereq then do
  80.     prtopt = rtezrequest('Current Scion database: '||dbname||NL||,
  81.       NL||'Please make your choice: '||,
  82.       NL||' 1. Descendant Chart - all descendants'||,
  83.       NL||' 2. Descendant Chart - male descendants'||,
  84.       NL||'    (mention daughters, without children)'||,
  85.       NL||' 3. Descendant Chart - male descendants'||,
  86.       NL||'    (leave out daughters)'||,
  87.       '',' _1 | _2 | _3 |E_xit','PrintDescendant v'||versionstr||' by Freddy Ariës')
  88.     if prtopt = 0 then
  89.       EXIT
  90.  
  91.     irn = rtgetlong(,'Enter the IRN of the person whose'||,
  92.             NL||'descendants you want to print: '||,
  93.             NL,'Input Request:','_Continue')
  94.     irn = abs(irn)
  95.     useirn = rtezrequest('Do you want to output the IRNs'||,
  96.               NL||'(the record numbers) as well?'||,
  97.               '',' _Yes| _No ','Input Request:')
  98.   end
  99.   else do
  100.     /* No use in asking for input if we're not allowed to output anything */
  101.     Tell("1. Descendant Chart - all descendants")
  102.     Tell("2. Descendant Chart - male descendants (mention daughters, without children)")
  103.     Tell("3. Descendant Chart - male descendants (leave out daughters)")
  104.     TellNN("Your choice: ")
  105.     pull prtopt
  106.     prtopt = CheckAnswer(prtopt)
  107.  
  108.     TellNN("Enter the IRN of the person whose descendants you want to print: ")
  109.     pull irn
  110.  
  111.     TellNN("Do you want to output the IRNs (numbers) as well (y/n)? ")
  112.     pull instr
  113.     Tell("")
  114.     if left(instr, 1) = "Y" then useirn = 1
  115.     else useirn = 0
  116.   end
  117. end
  118.  
  119. irn = CheckIRN(irn)
  120.  
  121. EXISTPERSON irn
  122. if RESULT ~= 'YES' then
  123.   TermError("No person with IRN "||irn||" in the current database.")
  124.  
  125. if prtopt > 1 then do
  126.   GETSEX irn
  127.   parsex = RESULT
  128.   if prtopt = 3 & parsex ~= malesex then
  129.     TermError("Person isn't male - nothing to print.")
  130. end
  131.  
  132. if outp then do
  133.   /* No use trying to get input if we're not allowed to ask anything */
  134.   pname = GetNameStr(irn, 0)
  135.   if prtopt = 1 | parsex = malesex then do
  136.     if usereq then do
  137.       valcont = rtezrequest('The selected person is: '||NL||pname||'.'||,
  138.         NL||'Continue?','_Continue| _Abort','PrintDescendant Request:')
  139.       if valcont = 0 then
  140.         EXIT
  141.     end
  142.     else do
  143.       TellNN("Current person is "||pname||". Continue? (y/n) ")
  144.       pull valcont
  145.       if left(valcont, 1) ~= 'Y' then
  146.         TermError("Ok.")
  147.     end
  148.   end
  149.   else do
  150.     /* with prtopt = 2, we would only print the (generation I) female and
  151.      * her husbands, but no children!
  152.      */
  153.     if usereq then do
  154.       valcont = rtezrequest("WARNING!!! Person "||NL||pname||,
  155.         NL||"is not male! Continue anyway?",'_Continue| _Abort','PrintDescendant Request:')
  156.       if valcont = 0 then
  157.         EXIT
  158.     end
  159.     else do
  160.       Tell("WARNING! Person "||pname||" isn't male!")
  161.       TellNN("Continue anyway? (y/n) ")
  162.       pull valcont
  163.       if left(valcont, 1) ~= 'Y' then
  164.         TermError("Ok.")
  165.     end
  166.   end
  167. end
  168.  
  169. /* TO DO: (at this location:)
  170.  * If the person has multiple marriages, output the spouse name, IRN
  171.  * and FGRN to screen, and let the user select one (1..x), or all (0)
  172.  */
  173.  
  174. if outp & outname = "" then do
  175.   if usereq then do
  176.     odev = rtezrequest('Current Scion database: '||dbname||,
  177.       NL||'Where should the output be sent to?'||,
  178.       NL,' _File |_Printer|_Screen|_Nowhere','PrintDescendant v'||versionstr||' by Freddy Ariës')
  179.     select
  180.       when odev = 1 then do
  181.         /* We need a file requester for further data */
  182.         dblen = length(dbname)
  183.         if dblen>6 & right(dbname, 6)=".SCION" then
  184.           dbname=left(dbname, dblen - 6)
  185.         outname = rtfilerequest('RAM:',dbname||'.DSC','Output filename')
  186.         if outname = '' then
  187.           outname = dbname||'.DSC'
  188.       end
  189.       when odev = 2 then
  190.         outname = 'PRT:'
  191.       when odev = 3 then
  192.         outname = 'STDOUT'
  193.       otherwise
  194.         EXIT
  195.         /* You selected 'Nowhere' */
  196.     end
  197.   end
  198.   else do
  199.     Tell("Enter output file (filename with complete path, or PRT: for printer,")
  200.     TellNN("or STDOUT for screen): ")
  201.     pull outname
  202.     if outname = "" then
  203.       outname = "STDOUT"
  204.   end
  205. end
  206.  
  207. /* Anyone know a better way to translate numbers into Roman? */
  208. GenerationS.1 = "I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX"
  209. GenerationS.2 = "XXI XXII XXIII XXIV XXV XXVI XXVII XXVIII XXIX XXX XXXI XXXII XXXIII XXXIV XXXV XXXVI XXXVII XXXVIII IXL XL"
  210. MaxChild = 26
  211.  
  212. /* Printer Codes, some of which are currently unused: */
  213. ESC = '1B'x
  214. prtinit = ESC||"#1";     /* ESC#1 initialize      */
  215. prtundon = ESC||"[4m";   /* ESC[4m underline on   */
  216. prtundoff = ESC||"[24m"; /* ESC[24m underline off */
  217. prtdson = ESC||"[1m";    /* ESC[1m boldface on    */
  218. prtdsoff = ESC||"[22m";  /* ESC[22m boldface off  */
  219. prtnlqon = ESC||"[2"||'22'x||"z"; /* ESC[2"z NLQ on */
  220. prtnlqoff = ESC||"[1"||'22'x||"z"; /* ESC[1"z NLQ off */
  221.  
  222. if ~usereq then
  223.   Tell("Printing...")
  224.  
  225. OpenPrinter()
  226.  
  227. childnums = irn; childgens = "1"
  228. alcount = 0; chcount = 0
  229.  
  230. do while childnums ~= ""
  231.   irn = word(childnums, 1)
  232.   cgen = word(childgens, 1)
  233.   if cgen ~= currgen then do
  234.     alcount = 0
  235.     /* New generation: reset alfabet counter */
  236.     currgen = cgen
  237.     genchild = 0
  238.   end
  239.   childnums = delstr(childnums, 1, length(irn)+1)
  240.   childgens = delstr(childgens, 1, length(currgen)+1)
  241.  
  242.   ccnt = 1
  243.   /* Sex to use with options 2 and 3 */
  244.   GETSEX irn
  245.   parsex = RESULT
  246.  
  247.   g1 = GetPersonStr(irn)
  248.   mnum = 0
  249.   GETMARRIAGE irn mnum
  250.   fgrn = RESULT
  251.   EXISTFAMILY fgrn
  252.   ftrue = RESULT
  253.  
  254.   do while ftrue = 'YES'
  255.     m1 = GetMarriageStr(fgrn)
  256.     ptn = GetPartnerIRN(fgrn, irn)
  257.     if ptn ~= 0 then do
  258.       if m1 ~= "" then m1 = m1||' '
  259.       m1 = m1||GetPersonStr(ptn)
  260.     end
  261.     if m1 ~= "" then m1 = ", m: "||m1
  262.     if ccnt = 1 then do
  263.       ggs = GetGenStr(currgen, 0)
  264.       if currgen > 1 then do
  265.         alcount = alcount + 1
  266.         ggs = ggs||D2C(alcount+96)
  267.       end
  268.       ggs = left(ggs||".       ", fill)
  269.       m1 = ggs||g1||m1||'.'
  270.       ccnt = 0
  271.     end
  272.     else
  273.       m1 = copies(' ',fill)||g1||m1||'.'
  274.     PrintLines(m1, fill)
  275.     if prtopt ~= 3 | parsex = malesex then
  276.       chcount = chcount + PrintChildren(fgrn, parsex)
  277.     PrintLF()
  278.     mnum = mnum + 1
  279.     GETMARRIAGE irn mnum
  280.     fgrn = RESULT
  281.     EXISTFAMILY fgrn
  282.     ftrue = RESULT
  283.   end
  284.   if mnum = 0 then do
  285.     m1 = GetGenStr(currgen,fill)||g1
  286.     PrintLines(m1, fill)
  287.     if currgen = 1 then
  288.       PrintLines("No marriages are recorded for this person.", 0)
  289.     PrintLF()
  290.   end
  291. end
  292. if currgen = 1 & chcount = 0 then do
  293.   if prtopt = 1 then
  294.     PrintLines("No descendants are recorded for person.")
  295.   else 
  296.     PrintLines("No male descendants are recorded for person.")
  297. end
  298.  
  299. writeln(prtdev, prtnlqoff);
  300. close(prtdev)
  301. if usereq then
  302.   rtezrequest('Output ready.','E_xit','PrintDescendant Message:')
  303. else
  304.   Tell("Done.")
  305. EXIT
  306.  
  307. ParseArguments:
  308. if noirn = "NOIRN" then useirn = 0
  309. else if noirn = "QUIET" || noirn = "NOREQ" then do
  310.   outval = noirn
  311.   noirn = ""
  312. end
  313. else do
  314.   outval = mgen
  315.   mgen = noirn
  316.   noirn = ""
  317. end
  318. if mgen = "QUIET" || mgen = "NOREQ" then do
  319.   outval = mgen
  320.   mgen = ""
  321. end
  322.  
  323. MaxGens = 40; /* due to the Roman numbers, we can't handle more */
  324. if mgen ~= "" then do
  325.   if DATATYPE(mgen, 'w') & mgen > 0 & mgen < MaxGens then
  326.     MaxGens = mgen
  327. end
  328.  
  329. if outval = "QUIET" then do
  330.   usereq = 0
  331.   outp = 0
  332. end
  333. else if outval = "NOREQ" then
  334.   usereq = 0
  335.  
  336. if prtin = "" | prsirn = "" then do
  337.   prtopt = 0
  338.   if ~outp then TermError("Requires argument is missing.")
  339.     /* actually, with outp = 0, all it does is EXIT */
  340. end
  341. else do
  342.   prtopt = CheckAnswer(prtin)
  343.   irn = CheckIRN(prsirn)
  344.   /* Note that it was important to establish outp before calling these */
  345. end  
  346. return 0
  347.  
  348. OpenPrinter:
  349. /* Open the printer device and print out a nice header */
  350. if outname = "STDOUT" then
  351.   prtdev = stdout
  352. else do
  353.   prtdev = 'PRINTER'
  354.   if ~open(prtdev, outname, 'w') then
  355.     TermError("ERROR: Failed to open output file!")
  356. end
  357. writeln(prtdev, prtinit||prtnlqon)
  358. if prtopt = 1 then
  359.   prtstr = "DESCENDANT CHART - ALL DESCENDANTS"
  360. else if prtopt = 2 then
  361.   prtstr = "DESCENDANT CHART - ONLY MALE DESCENDANTS (TYPE I)"
  362. else
  363.   prtstr = "DESCENDANT CHART - ONLY MALE DESCENDANTS (TYPE II)"
  364. prtstr = prtundon||prtdson||prtstr||prtdsoff||prtundoff
  365. writeln(prtdev, prtstr)
  366. prtstr = prtdson||"Report printed on: "||date()||prtdsoff
  367. writeln(prtdev, prtstr)
  368. prtstr = copies('=', plwidth)
  369. writeln(prtdev, prtstr)
  370. return 0
  371.  
  372. PrintLines: PROCEDURE EXPOSE prtdev plwidth prtopt
  373. parse arg ostr, fill
  374. /* TO DO:
  375.  * if there are control strings within ostr (like prtdson or prtdsoff)
  376.  * don't include them in the length count
  377.  */
  378. do while ostr ~= ""
  379.   nnl = plwidth+1
  380.   if length(ostr) > plwidth then do
  381.     do until pc = ' ' | nnl = 1
  382.       pc = substr(ostr, nnl, 1)
  383.       nnl = nnl - 1
  384.     end
  385.     if nnl = 1 then do
  386.       prtstr = left(ostr, plwidth)
  387.       ostr = delstr(ostr, 1, nnl)
  388.     end
  389.     else do
  390.       prtstr = left(ostr, nnl)
  391.       ostr = delstr(ostr, 1, nnl+1)
  392.     end
  393.   end
  394.   else do
  395.     prtstr = ostr
  396.     ostr = ""
  397.   end
  398.   writeln(prtdev, prtstr)
  399.   if ostr ~= "" then
  400.     ostr = copies(' ',fill)||ostr
  401. end
  402. return 0
  403.  
  404. PrintLF:
  405. writeln(prtdev, "")
  406. return 1
  407.  
  408. PrintChildren:
  409. parse arg ffnum, parsx
  410. /* If we turn this into a PROCEDURE, we'll have to EXPOSE a lot!
  411.  * The disadvantage now is that we have to be extremely careful
  412.  * not to overwrite any global variables by accident!
  413.  */
  414. cidx = 0; cham = 0
  415. GETCHILD ffnum cidx
  416. chld = RESULT
  417. EXISTPERSON chld
  418. ctrue = RESULT
  419. nextgen = currgen + 1
  420. if nextgen > MaxGens then return cham
  421.   /* Maximum number of generations reached! */
  422. do while ctrue = 'YES'
  423.   cidx = cidx + 1
  424.   if prtopt > 1 then do
  425.     GETSEX chld
  426.     csx = RESULT
  427.   end
  428.   if prtopt ~= 3 | csx = malesex then do
  429.     cham = cham + 1
  430.     m1 = copies(' ',8)||cham||". "||GetChildStr(chld)
  431.     if (prtopt = 1 | csx = malesex) & HasChild(chld) then do
  432.       childnums = childnums||chld||' '
  433.       childgens = childgens||nextgen||' '
  434.       genchild = genchild + 1
  435.       if genchild > MaxChild then return 1
  436.       /* Maximum number of children reached! */
  437.       m1 = m1||", see "||GetGenStr(nextgen, 0)||D2C(genchild+96)
  438.     end
  439.     else
  440.       m1 = m1||GetDeathStr(chld)||GetMarriages(chld)
  441.     PrintLines(m1||'.', 11)
  442.   end
  443.   GETCHILD ffnum cidx
  444.   chld = RESULT
  445.   EXISTPERSON chld
  446.   ctrue = RESULT
  447. end
  448. return cham
  449.  
  450. GetGenStr: PROCEDURE EXPOSE GenerationS.
  451. parse arg gnum, fill
  452. if gnum <= 20 then
  453.   gstr = word(GenerationS.1, gnum)
  454. else if gnum <= 40 then
  455.   gstr = word(GenerationS.2, gnum)
  456. else
  457.   return ""
  458. if fill > 0 then
  459.   gstr = left(gstr||".       ",fill)
  460. return gstr
  461.  
  462. GetPersonStr: PROCEDURE EXPOSE useirn
  463. parse arg irn
  464. if irn ~= 0 then do
  465.   nstr = GetNameStr(irn)
  466.   nstr = nstr||GetBirthStr(irn)
  467.   nstr = nstr||GetDeathStr(irn)
  468. end
  469. else
  470.   nstr = "UNKNOWN"
  471. return nstr
  472.  
  473. GetChildStr: PROCEDURE EXPOSE useirn
  474. parse arg irn
  475. if irn ~= 0 then do
  476.   nstr = GetNameStr(irn)
  477.   nstr = nstr||GetBirthStr(irn)
  478. end
  479. else
  480.   nstr = "UNKNOWN"
  481. return nstr
  482.  
  483. HasChild: PROCEDURE EXPOSE prtopt malesex
  484. parse arg irn
  485. mnum = 0
  486. GETMARRIAGE irn mnum
  487. marr = RESULT
  488. EXISTFAMILY marr
  489. mtrue = RESULT
  490. do while mtrue = 'YES'
  491.   chnxt = 0
  492.   GETCHILD marr chnxt
  493.   ch = RESULT
  494.   EXISTPERSON ch
  495.   ct = RESULT
  496.   if prtopt < 3 then do
  497.     if ct = 'YES' then return 1
  498.   end
  499.   else do
  500.     /* For option 3: search for male children */
  501.     do while ct = 'YES'
  502.       GETSEX ch
  503.       csx = RESULT
  504.       if csx = malesex then return 1
  505.       chnxt = chnxt + 1
  506.       GETCHILD marr chnxt
  507.       ch = RESULT
  508.       EXISTPERSON ch
  509.       ct = RESULT
  510.     end
  511.   end
  512.   mnum = mnum + 1
  513.   GETMARRIAGE irn mnum
  514.   marr = RESULT
  515.   EXISTFAMILY marr
  516.   mtrue = RESULT
  517. end
  518. return 0
  519.  
  520. GetNameStr: PROCEDURE EXPOSE useirn
  521. parse arg gnum
  522. GETFIRSTNAME gnum
  523. name = RESULT
  524. if name ~= "" then name = name||" "
  525. GETLASTNAME gnum
  526. lname = RESULT
  527. if lname = "" then lname = "UNKNOWN"
  528. name = name||lname
  529. if useirn then name = name||" ["gnum"]"
  530. return name
  531.  
  532. GetBirthStr: PROCEDURE
  533. parse arg gnum
  534. GETBIRTHPLACE gnum
  535. bstr = RESULT
  536. GETBIRTHDATE gnum
  537. bdat = RESULT
  538. if bdat ~= "" & bstr ~= "" then bstr = bstr||" "
  539. bstr = bstr||bdat
  540. if bstr ~= "" then bstr = ", b: "||bstr
  541. return bstr
  542.  
  543. GetDeathStr: PROCEDURE
  544. parse arg gnum
  545. GETDEATHPLACE gnum
  546. dstr = RESULT
  547. GETDEATHDATE gnum
  548. ddat = RESULT
  549. if ddat ~= "" & dstr ~= "" then dstr = dstr||" "
  550. dstr = dstr||ddat
  551. if dstr ~= "" then dstr = ", d: "||dstr
  552. return dstr
  553.  
  554. GetMarriages: PROCEDURE EXPOSE useirn
  555. parse arg irn
  556. mstr = ""
  557. GETMARRIAGE irn 0
  558. mf = RESULT
  559. EXISTFAMILY mf
  560. if RESULT = 'YES' then do
  561.   mtrue = 1
  562.   GETMARRIAGE irn 1
  563.   m2 = RESULT
  564.   EXISTFAMILY m2
  565.   if RESULT = 'YES' then mset = 1
  566.   else mset = 0
  567. end
  568. else
  569.   mtrue = 0  
  570. mnum = 0
  571. do while mtrue
  572.   m1 = GetMarriageStr(mf)
  573.   if m1 ~= "" then m1  = m1||' '
  574.   ptn = GetPartnerIRN(mf, irn)
  575.   m1 = m1||GetPersonStr(ptn)
  576.  
  577.   if mset then mstr = ", m("||mnum||"): "||m1
  578.   else mstr = ", m: "||m1
  579.  
  580.   mnum = mnum + 1    
  581.   GETMARRIAGE irn mnum
  582.   mf = RESULT
  583.   EXISTFAMILY mf
  584.   if RESULT ~= 'YES' then mtrue = 0
  585. end
  586. return mstr
  587.  
  588. GetMarriageStr: PROCEDURE
  589. parse arg mf
  590. GETMARRYPLACE mf
  591. mstr = RESULT
  592. GETMARRYDATE mf
  593. mdat = RESULT
  594. if mdat ~= "" & mstr ~= "" then mstr = mstr||" "
  595. mstr = mstr||mdat
  596. return mstr
  597.  
  598. GetPartnerIRN: PROCEDURE
  599. parse arg fnum, inum
  600. GETPRINCIPAL fnum
  601. prn = RESULT
  602. GETSPOUSE fnum
  603. sps = RESULT
  604. if inum = prn then pnum = sps
  605. else if inum = sps then pnum = prn
  606. else pnum = 0
  607. EXISTPERSON pnum
  608. if RESULT ~= 'YES' then pnum = 0
  609. return pnum
  610.  
  611. CheckAnswer: PROCEDURE EXPOSE outp prtdev
  612. parse arg str
  613. str = left(str, 1)
  614. if ~DATATYPE(str, 'w') then
  615.   TermError("Arg(1): not a valid option number.")
  616. if str < 1 | str > 3 then
  617.   TermError("Arg(1): not a valid option number.")
  618. return str
  619.  
  620. CheckIRN: PROCEDURE EXPOSE outp prtdev
  621. parse arg str
  622. if ~DATATYPE(str, 'w') then
  623.   TermError("Arg(2): not a valid IRN.")
  624. return str
  625.  
  626. Tell: PROCEDURE EXPOSE outp
  627. parse arg str
  628. if outp then
  629.   writeln(stdout, str)
  630. return 0
  631.  
  632. TellNN: PROCEDURE EXPOSE outp
  633. parse arg str
  634. if outp then
  635.   writech(stdout, str)
  636. return 0
  637.  
  638. TermError: PROCEDURE EXPOSE outp prtdev usereq
  639. parse arg str
  640. /* If you turned off stdout, no error messages will be shown! */
  641. if usereq then
  642.   rtezrequest(str,'E_xit','PrintDescendant Message:')
  643. else do
  644.   Tell(str || '0A'x)
  645. end
  646. close(prtdev)
  647. EXIT
  648.  
  649. /* Let's make sure you get a nice message when you turn off the printer :-) */
  650.  
  651. IOERR:
  652. bline = SIGL
  653. say "I/O error #"||RC||" detected in line "||bline||":"
  654. say sourceline(bline)
  655. EXIT
  656.